<%@page import="cn.edu.nju.ws.sview.wyge.relations.datasets.DatasetItem"%>
<%@page import="cn.edu.nju.ws.sview.wyge.relations.adataset.CustomDataset"%>
<%@page import="cn.edu.nju.ws.sview.rdf.URIResource"%>
<%@page import="cn.edu.nju.ws.sview.views.Group"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>编辑关系</title>
  </head>
   <link rel="icon" href="/sview/favicon.ico" />
  <link rel="stylesheet" href="../css/group/bootstrap-responsive.min.css" type="text/css"></link>
  <link rel="stylesheet" href="../css/group/bootstrap.min.css" type="text/css"></link>
    <link rel="stylesheet" href="../css/smoothness/jquery-ui-1.8.16.custom.css" type="text/css"></link>
  <link rel="stylesheet" type="text/css" href="/sview/css/easyui.css" />
  <link rel="stylesheet" href="../css/flexigrid.pack.css" type="text/css"></link>
  <link rel="stylesheet" type="text/css" href="/sview/css/layout.css" />
  <link rel="stylesheet" type="text/css" href="/sview/css/relations/relation_edit.css" />
<script type="text/javascript" src="/sview/script/jquery.js"></script>
<script type="text/javascript" src="/sview/script/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/sview/script/flexigrid.pack.js"></script>
<script type="text/javascript" src="/sview/script/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="/sview/script/relations/relation_edit.js"></script>
<script type="text/javascript" src="/sview/script/relations/URILocalname.js"></script>
 <%
 	String lang = request.getParameter("lang");
	if(lang!=null &&lang.equals("en")){
		request.getRequestDispatcher("relation_edit.jsp").forward(request,response);
		return;
	}else if(lang==null){
		lang="zh" ;
	}
 	String ds_type = request.getParameter("ds_type");
 	String idStr = request.getParameter("idStr");
 	int ds_id = Integer.valueOf((String)request.getParameter("ds_id"));
 	String ds_name = DatasetItem.getShowNameByDatasetID(ds_id, ds_type, lang);
//	if (ds_type.equals("custom")) {
//		ds_name = CustomDataset.getNameByCustomDatasetID(ds_id);
//	} else if (ds_type.equals("uri")) {
//		try {
//			//name = URIIDCache.getInstance().getURI(datasetId);
//			ds_name = URIResource.getLabel(ds_id, lang);
//		} catch (Throwable e) {
//			e.printStackTrace();
//		}
//	}					
	
 	int relation_id = Integer.valueOf((String)request.getParameter("relation_id"));
 	if(session.getAttribute("relation"+relation_id) == null){//go to create or index
 	}
 	String uname = (String)session.getAttribute("user");
 	if(uname == null){//ask for login
 	}
 	if(session.getAttribute("groupName") == null){//ask for group choosing
 	}
 	String refresh = request.getParameter("refresh");//whether get info from db(original) or session(refresh)
 	if(refresh == null){
 		refresh = "original";
 	}
 	String ugname = (String)request.getSession().getAttribute("groupName");
 	int gid=-1;
 	if(ugname!=null){
 		gid = Group.getGroupIdByName(ugname);
 	}
  %>
 
  <body>
  	<jsp:include page="/vheader_zh.jsp" flush="true">
       <jsp:param name="f" value="d"/>
    </jsp:include>
  	<div class="container">
  		<!-- <div class="titleDiv"><span>Relation Edit</span></div> -->
  		<div class="top">
			<div class="mspacing"></div>
			<div class="operation"> 编辑关系 </div>
			<div class="right">
				<a class="back" href="javascript:void()">返回数据集 "<span style="font-style: italic;"><%=ds_name %></span>"</a>
			</div>
		</div>
  		<div class="content">
  			<!-- <div class="middle"> -->
  				<div class="metaDiv">
					<div class="barDiv"><span>关系信息</span></div>
					<!--<div class="btnDiv btn-toolbar">
						 <div class="btn-group">
							<a id="save_btn" class="btn" href="javascript:void(0);" title="Save"><span id="saveIcon">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Save</span></a>
						    <a id="back_btn" class="btn" href="javascript:void(0);" title="Cancel"><span id="cancelIcon">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cancel</span></a>
						    <a id="reset_btn" class="btn" href="javascript:void(0);" title="Reload"><span id="refreshIcon">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reload</span></a>
						</div> 
					</div>-->
					<div class="panel">
						<ul id="panel0" class="currUl">
							<li id="rel_name" class="metaBlock"><span>关系名:</span><input id="rel_name_input" class="input-medium text_ipt rel_name" type="text" /></li>
							<li id="rel_roles" class="metaBlock"><span>变量名:</span>
								<ul id="role_sel"></ul>
							</li>
							<li id="rel_patterns" class="metaBlock">
								<span>规则:</span>
								<ul id="patterns"></ul>
							</li>
						</ul>
						
					</div>
					
					<div class="btnDiv btn-toolbar">
							<!-- <input id="reset_btn" class="btn btn-success" type="button" value="Reset" /> -->
							<input id="cancel_btn" class="btn btn-success" type="button" value="取消" />
							<input id="save_btn" class="btn btn-success" type="button" value="保存" />
					</div>
				</div>
				<div class="resultDiv">
					<div class="barDiv"><span>结果</span></div>
					<div id="edit_result" class="panel"></div>
				</div>
  			<!--</div>
  			 <div class="right"></div> -->
  		</div>
  	</div>
  	<div id="vOperateDiv" title="Refinement" class="panel row-fluid"  style="display:none">
  		<div id="tabs" class="span">
	  		<ul class="nav nav-pills">
			  <li id="expandTab" class="active optab"><a href="javascript:void(0);">扩展</a></li>
			  <li id="restrictTab" class="optab"><a href="javascript:void(0);">约束</a></li>
			  <li id="bindTab" class="optab"><a href="javascript:void(0);">绑定</a></li>
			</ul>
  		</div>
  		<div id="panels">
			<div id="expandDiv" class="opdiv panel span"></div>
			<div id="restrictDiv" class="opdiv panel span origin" style="display:none"></div>
			<div id="bindDiv" class="opdiv panel span origin" style="display:none"></div>
			<div id="infoDiv" class="infodiv panel span origin" style="display:none"></div>
  		</div>
  	</div>
  	<div id="onloading" class="section" style="display: none;">
			<div style="text-align: center">
				<p>&nbsp;</p>
				<p>正在加载数据, 请稍候...</p>
			</div>
	</div>
	<div id="ask" class="section" style="display: none;">
		<span></span>
	</div>
  	<input type="hidden" id="user" value="<%=uname %>" />
  	<input type="hidden" id="lang" value="<%=lang %>" />
  	<input type="hidden" id="ds_id" value="<%=ds_id %>" />
  	<input type="hidden" id="ds_type" value="<%=ds_type %>" />
  	<input type="hidden" id="idStr" value="<%=idStr %>" />
  	<input type="hidden" id="relation_id" value="<%=relation_id %>" />
  	<input type="hidden" id="refresh" value="<%=refresh %>" />
  	<input type="hidden" id="gid" value="<%=gid %>" />
<jsp:include page="/vfooter_zh.jsp"></jsp:include>
  </body>
</html>
